package bomberman.model;

import java.awt.Graphics;

import bomberman.MainGame;
import bomberman.runable.MyRunableBoom;
import bomberman.runable.MyRunableBoomChange;
import bomberman.swing.BomJPanel;
import bomberman.util.Constants;
import bomberman.util.GameMap;

public class Boom {
	private int x;
	private int y;
	
	// 爆炸效果大小
	private int size = Constants.BOOM_SIZE_BIG;

	// 是否消失
	private boolean isLive = false;
	
	public Boom(int x, int y){
		this.x = x;
		this.y = y;
//		MyRunableThreadPool.getExecutorService().execute(new MyRunableBoom(this));
//		MyRunableThreadPool.getExecutorService().execute(new MyRunableBoomChange(this));
		new Thread(new MyRunableBoom(this)).start();
		new Thread(new MyRunableBoomChange(this)).start();
	}
	
	public void draw(Graphics g) {
		g.drawImage(GameMap.img_boom_array[size], x, y, MainGame.jPanelIndex);
	}
	
	
	/**
	 * 添加爆炸效果
	 */
	public void addBoom(){
		BomJPanel.booms.add(this);
	}
	
	/**
	 * 移除爆炸效果
	 */
	public void remove(){
		if(BomJPanel.booms.contains(this)){
			BomJPanel.booms.remove(this);
		}
		
		// 显示道具
		showProperty();
	}
	
	
	/**
	 * 判断当前位置有无道具
	 */
	public void showProperty(){
		for(Property p : BomJPanel.properties){
			if(p.showProperty(x, y)){
				break;
			}
		}
	}
	
	
	public int getX() {
		return x;
	}

	public void setX(int x) {
		this.x = x;
	}

	public int getY() {
		return y;
	}

	public void setY(int y) {
		this.y = y;
	}

	public int getSize() {
		return size;
	}

	public void setSize(int size) {
		this.size = size;
	}

	public boolean isLive() {
		return isLive;
	}

	public void setLive(boolean isLive) {
		this.isLive = isLive;
	}
}
